/**
 * 
 * @author  phoenics@126.com
 * @version v.0.1
 * @date  2018年3月14日 下午2:05:32 
 * 
 */
package com.github.phoenics.militia.common.auth;

import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;

/**
 *
 */
//@Component
public class TokenAuthenticationProvider implements AuthenticationProvider {
	private static org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TokenAuthenticationProvider.class);
	@Override  
    public Authentication authenticate(Authentication authentication) throws AuthenticationException {  
        if (authentication != null) {  
            authentication.setAuthenticated((authentication.getPrincipal() != null));  
        }  
        return authentication;  
    }  
  
    @Override  
    public boolean supports(Class<?> authentication) {  
        return authentication.isAssignableFrom(TokenAuthentication.class);
    }  
}
